<?php $url = new Url();?>
<div id="main" class="nosidebar">                
    <div id="content">

        <h2>Thành viên</h2>

        <?php $this->widget("TabSetting");?>

        <div class="tab-content" id="tab-content-members" style="display: block;">
            <div class="splitcontentleft">
                <table class="list members">
                    <thead>
                        <tr>
                            <th>Tài khoản</th>
                            <th>Vai trò</th>
                            <th style="width:15%"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr id="member-1228" class="odd member">
                            <td class="user"><a href="<?php echo $url->createUrl("user/detail",array("user_id"=>$_SESSION['user_pm']['user_id'])); ?>"><?php echo $_SESSION['user_pm']['fullname']; ?></a></td>
                            <td class="roles" style="text-align: center;">
                                <span id="member-1228-roles">Chủ dự án</span>                                
                                <!--<p>
                                    <label><input checked="checked" id="membership_role_ids_" name="membership[role_ids][]" value="3" type="checkbox"> Manager</label><br>

                                    <label><input id="membership_role_ids_" name="membership[role_ids][]" value="4" type="checkbox"> Developer</label><br>

                                    <label><input id="membership_role_ids_" name="membership[role_ids][]" value="5" type="checkbox"> Reporter</label><br>
                                </p>                                
                                <p><input class="small" name="commit" value="Đổi" type="submit"></p>-->
                            </td>
                            <td class="buttons">
                                <!--<a class="icon icon-edit" href="javascript:">Sửa</a>
                                <a href="javascript:" class="icon icon-del" rel="nofollow">Xóa</a>-->
                            </td>
                        </tr>
                        <?php for($i=0;$i<count($data_member);$i++){?>
                        <tr class="<?php if(($i%2) == 1){echo "odd";}else{echo "even";} ?> member" id="member_row_<?php echo $data_member[$i]['member_id']; ?>">
                            <td class="user">
                                <a href="<?php echo $url->createUrl("user/detail",array("user_id"=>$data_member[$i]['user_id'])); ?>"><?php echo $data_member[$i]['fullname']; ?></a>
                            </td>
                            <td class="roles" style="text-align: center;">
                                <span id="member-1228-roles"><?php echo $data_member[$i]['role_name']; ?></span>                                            
                            </td>
                            <td class="buttons">
                                <!--<a class="icon icon-edit" href="javascript:">Sửa</a>-->
                                <a class="icon icon-del" rel="nofollow" href="javascript:" onclick="delete_member(<?php echo $data_member[$i]['member_id']; ?>)">Xóa</a>
                            </td>
                        </tr>
                        <?php } ?>                        
                    </tbody>
                </table>
            </div>

            <div class="splitcontentright">                
                <fieldset><legend>Thành viên mới</legend>

                    <!--<p><label for="principal_search">Search for user or group:</label><input id="principal_search" name="principal_search" type="text"></p>-->                                    

                    <div id="principals">                    
                        <?php 
                            foreach($data_user as $row){ 
                                if($row['user_id'] != $_SESSION['user_pm']['user_id'] && $row['project_id'] != $_SESSION['project_pm']['project_id']){
                                ?>                                                                
                        <label><input id="membership_user_ids_" name="membership[user_ids][]" value="<?php echo $row['user_id']; ?>" type="checkbox"><?php echo $row['fullname']; ?> (<?php echo $row['username']; ?>)</label> 
                        <?php } } ?>                       
                    </div>

                    <p>Vai trò:
                        <?php foreach($data_role as $row){ ?>
                        <label><input id="membership_role_<?php echo $row['role_id']; ?>" name="membership" value="<?php echo $row['role_id']; ?>" type="checkbox" class="unique"><?php echo $row['role_name']; ?></label>
                        <?php } ?>
                        <!--<label><input id="membership_role_ids_" name="membership" value="4" type="checkbox"> Developer</label>
                        <label><input id="membership_role_ids_" name="membership" value="5" type="checkbox"> Reporter</label>-->
                    </p>

                    <p><input id="member-add-submit" name="commit" value="Thêm" type="button" onclick="add_member()"></p>
                </fieldset>                
            </div>
        </div>
        <div style="clear:both;"></div>
    </div>
</div>

<?php include "add_member.js.php"; ?>